package com.acme;

import com.acme.domain.account.*;
import com.acme.domain.bank.*;
import com.acme.exceptions.ClientExistsException;
import com.acme.exceptions.ClientNumberException;
import com.acme.exceptions.NotEnoughFundsException;

class BankApplication {
	public static void main(String[] args){
		Account acc;
		try {
			acc = new SavingsAccount(-3);
		} catch (IllegalArgumentException ex){
			System.out.println("Error creating account (negative " +ex.getMessage() + " value)");
		}
		try {
			acc = new CheckingAccount(3, -5);
		} catch (IllegalArgumentException ex){
			System.out.println("Error creating account (negative " + ex.getMessage() + " value)");
		}
		acc = new SavingsAccount(10);

		try {
			acc.withdraw(30);
		} catch(NotEnoughFundsException ex){
			System.out.println(ex.toString());
		}
		acc = new CheckingAccount( 10, 30);
		try {
			acc.withdraw(15);
			acc.withdraw(100);
		} catch(NotEnoughFundsException ex){
			System.out.println(ex.toString() + " Current amount "+acc.getBalance()+
					". Avaliable total: " + acc.maximumAmountToWithdraw());
		}
		
		Bank db = new Bank();
		try {
			db.addClient(new Client(acc, Gender.MALE, "Petrov"));
			db.addClient(new Client(acc, Gender.MALE, "Petrov"));
		} catch (ClientExistsException e) {
			e.printStackTrace();
		} catch (ClientNumberException e) {
			e.printStackTrace();
		}
		
	}
	
}